﻿// -----------------------------------------------------------------------
// <copyright file="MostPlayedController.cs" company="Abyssalsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Metal.Intelligence.MostPlayed
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class MostPlayedController
    {
        #region Members

        /// <summary> The view used to communicate with the mask </summary>
        private static IMostPlayedView view;

        #endregion

        /// <summary>
        /// Initializes a new instance of the EqualizerController class.
        /// </summary>
        /// <param name="iView">Interface to communicate with the mask</param>
        public MostPlayedController(IMostPlayedView iView)
        {
            view = iView;
            this.SubscribeToViewEvents();
        }

        /// <summary>
        /// Subscribe to events defined in the view
        /// </summary>
        private void SubscribeToViewEvents()
        {
            try
            {
                view.MaskLoad += new EventHandler(this.OnMaskLoad);
                view.MaskClose += new EventHandler(this.OnMaskClose);
                view.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.OnControlAdded);
            }
            catch (Exception ex)
            {
                Metal.User.UserMessage.ShowError(ex);
            }
        }

        #region Mask events

        /// <summary>
        /// This method is called when the mask is loaded.
        /// </summary>
        /// <param name="sender">Object sender</param>
        /// <param name="e">Event arguments</param>
        private void OnMaskLoad(object sender, EventArgs e)
        {
            try
            {
            }
            catch (Exception ex)
            {
                Metal.User.UserMessage.ShowError(ex);
            }
        }

        /// <summary>
        /// This method is called when the mask is closed.
        /// </summary>
        /// <param name="sender">Object sender</param>
        /// <param name="e">Event arguments</param>
        private void OnMaskClose(object sender, EventArgs e)
        {
            try
            {
            }
            catch (Exception ex)
            {
                Metal.User.UserMessage.ShowError(ex);
            }
        }

        /// <summary>
        /// This method is called when a control is added on the mask
        /// </summary>
        /// <param name="sender">Object sender</param>
        /// <param name="e">Event arguments</param>
        private void OnControlAdded(object sender, System.Windows.Forms.ControlEventArgs e)
        {
            try
            {
                //if (e.Control.GetType() == typeof(Gui.Controls.MetalSlider))
                //{
                //    (e.Control as Gui.Controls.MetalSlider).Scroll += new System.Windows.Forms.ScrollEventHandler(this.OnSliderDrag);
                //}
                //else if (e.Control.GetType() == typeof(Gui.Controls.MetalPanel))
                //{
                //    e.Control.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.OnControlAdded);
                //}
            }
            catch (Exception ex)
            {
                Metal.User.UserMessage.ShowError(ex);
            }
        }

        #endregion
    }
}
